<?php
Loader::loadFile('config.php', "modules/InnoForum");

Loader::loadClass('DateUtilEx', "modules/InnoForum/pnincludes");
Loader::loadClass('ObjectUtilEx', "modules/InnoForum/pnincludes");
Loader::loadClass('PNObjectEx', "modules/InnoForum/pnincludes");
Loader::loadClass('PNObjectExArray', "modules/InnoForum/pnincludes");
Loader::loadClass('DBUtilEx', "modules/InnoForum/pnincludes");
Loader::loadClass('SecurityUtilEx', "modules/InnoForum/pnincludes");
Loader::loadClass('InnoUtil', "modules/InnoForum/pnincludes");

/**
 * initialise block
 * 
 * @author       The PostNuke Development Team
 */
function InnoForum_Searchblock_init()
{

}

/**
 * get information on block
 * 
 * @author       The PostNuke Development Team
 * @return       array       The block information
 */
function InnoForum_UserSearchblock_info()
{
    return array('text_type'      => 'Search Topics',
                 'module'         => 'InnoForum',
                 'text_type_long' => 'Search Topics',
                 'allow_multiple' => true,
                 'form_content'   => false,
                 'form_refresh'   => false,
                 'show_preview'   => true);
}

/**
 * display block
 * 
 * @author       The PostNuke Development Team
 * @param        array       $blockinfo     a blockinfo structure
 * @return       output      the rendered bock
 */
function InnoForum_UserSearchblock_display($blockinfo)
{

    $modname  = 'InnoForum';

    $vars = pnBlockVarsFromContent($blockinfo['content']);
    $modinfo = pnModGetInfo(pnModGetIDFromName($modname));
    $directory = $modinfo['directory'];

    //load render
    $render = pnRender::getInstance($modname);
/*
    //assign to view
    $render->assign('list', $vars);
    $render->assign('modulepath', 'modules/' . $directory);
    $render->assign('setting',InnoUtil::getSetting());
    $render->assign('vars',$vars);
*/

    // Populate block info and pass to theme
    $blockinfo['content'] = $render->fetch('block_search.htm');
    return themesideblock($blockinfo);

}


/**
 * modify block settings
 * 
 * @author       The PostNuke Development Team
 * @param        array       $blockinfo     a blockinfo structure
 * @return       output      the bock form
 */
function InnoForum_UserSearchblock_modify($blockinfo)
{
  $vars = pnBlockVarsFromContent($blockinfo['content']);
  //load render  
	return '';
}


/**
 * update block settings
 * 
 * @author       The PostNuke Development Team
 * @param        array       $blockinfo     a blockinfo structure
 * @return       $blockinfo  the modified blockinfo structure
 */
function InnoForum_UserSearchblock_update($blockinfo)
{
    
    // Get current content
    $vars = pnBlockVarsFromContent($blockinfo['content']);

    // write back the new contents
    $blockinfo['content'] = pnBlockVarsToContent($vars);

    // clear the block cache
    $pnRender = pnRender::getInstance('InnoForum');
    $pnRender->clear_cache('block_search.htm');
    
    return $blockinfo;
}
